<?php

require_once dirname(__FILE__) . '/../lib/doctor_educationGeneratorConfiguration.class.php';
require_once dirname(__FILE__) . '/../lib/doctor_educationGeneratorHelper.class.php';

/**
 * doctor_education actions.
 *
 * @package    docplus.co.za
 * @subpackage doctor_education
 * @author     Fox Matuku
 * @version    SVN: $Id: actions.class.php 23810 2009-11-12 11:07:44Z Kris.Wallsmith $
 */
class doctor_educationActions extends autoDoctor_educationActions
{

    public function preExecute()
    {
        $this->getUser()->setCurrentRoute("doctor_profile");
        if ($this->getUser()->getType() == "Doctor")
        {
            $this->doctorId = $this->getUser()->getDoctor()->getId();
        }
        else
        {
            $this->doctorId = $this->getUser()->getDoctorId();
        }
        parent::preExecute();
    }

    public function executeNew(sfWebRequest $request)
    {
        $this->form = $this->configuration->getForm();
        $this->form->setDefault("doctor_id", $this->doctorId);
        $this->doctor_education = $this->form->getObject();
    }

    protected function buildQuery()
    {
        $query = parent::buildQuery();
        $query->addWhere('a.doctor_id = ?', $this->doctorId);
        return $query;
    }

}
